var issn_tm={};
var tm;
function hint(text,obj){
    if(text == '<br>'||text == '')return;
    g('bubble_text2').innerHTML="<table style='width:100%;margin:25px 0 0 20px;padding-right:30px' cellpadding=0 cellspacing=0><tr class=libtr>"+
        "<th>"+I18N["hint"]["lib"]+
        "<th>"+I18N["hint"]["callno"]+
        "<th>"+I18N["hint"]["total"]+text+"</table>";
    g('bubble2').style.display='';
    g('bubble2').style.top=getPos(obj).y+20+'px';
    g('bubble2').style.left=getPos(obj).x-490+'px';
}
function prnnavigate(total,indx,bulk,url){
	 if(total>1000){total=1000;}
    	 var page=Math.floor((indx-1)/bulk+1);
         var max=(total-1)/bulk+1;
         var indx2;
         var url=url.replace(/pag=nxt/g,"pag=now");
         document.write("<div>");
         if(indx>bulk){
                 indx2=indx-bulk;
                 url=url.replace(/jump=[0-9]*/g,"jump="+indx2);
                 document.write("<a href='"+url+"'>&lt;"+I18N["hint"]["prev"]+"</a>&nbsp;");
         }
         for(var i=page-10;i<page+10;i++){
                 if(i<1||i>max){continue;}
                 if((i-1)*bulk+1==indx){
                         document.write("<span class=curpage>"+i+"</span>");
                 }
                 else{
                         indx2=(i-1)*bulk+1;
                         url=url.replace(/jump=[0-9]*/g,"jump="+indx2);
                         document.write("<a href='"+url+"'>"+i+"</a>");
                 }
                 document.write("&nbsp;");
         }
         if(total>indx+bulk-1){
                 indx2=indx+bulk;
                 url=url.replace(/jump=[0-9]*/g,"jump="+indx2);
                 document.write("&nbsp;<a href='"+url+"&pag=now'>"+I18N["hint"]["next"]+"&gt;</a>");
         }
         document.write("</div>");
}

 function showfacet(json){
	 var i; var topten='';
	 var plus=json["toomany"]==1?"+":"";
	 var reg = new RegExp("(.*?),(.*)", "i");
	 for(var type in I18N["types"]){
		 i=0;topten+='<div class=facetitle onclick="this.nextSibling.style.display=this.nextSibling.style.display==\'\'?\'none\':\'\';">'+I18N["types"][type]+'：</div><div><ul id=topten>';
		 for(var key in json[type]){
			 i++;if(i==6){topten+='</li><span style="display:none">'}
			 if ((type=='WLN'||type=='WSL'||type=='CLC'||type=='WFM')&&reg.test(key)){
				 if(type=='CLC'){
					 topten+='<li><a onclick="refine(\''+type+'\',\''+RegExp.$1+'?\')">'+RegExp.$2+': '+RegExp.$1+'('+json[type][key]+plus+')</a>';
				 }else if(type=='WSL'){
					 topten+='<li><a onclick="refine(\''+type+'\',\''+RegExp.$1+'?\')">'+RegExp.$2+'('+json[type][key]+plus+')</a>';
				 }else{
					 topten+='<li><a onclick="refine(\''+type+'\',\''+RegExp.$1+'\')">'+RegExp.$2+'('+json[type][key]+plus+')</a>';
				 }
			 }
			 else{topten+='<li><a onclick="refine(\''+type+'\',\''+key+'\')">'+key+'('+json[type][key]+plus+')</a>';}
		 }
		 if(i>=6){topten+='</span><span onclick="this.previousSibling.style.display=this.previousSibling.style.display==\'\'?\'none\':\'\';this.lastChild.innerHTML=this.lastChild.innerHTML==\''+I18N["hint"]["showmore"]+'\'?\''+I18N["hint"]["show5"]+'\':\''+I18N["hint"]["showmore"]+'\'"><li style="cursor:pointer">'+I18N["hint"]["showmore"]+'</li></span>';}
		 topten+='</ul></div>';
	 }
	 g('facetcon').innerHTML=topten;
	 topten='';i=0;
	 var min=1;
	 for(var key in json["WSU"]){
		 i++;if(i==20){topten+='<span style="display:none">';}else if(i==1){var max=json["WSU"][key];}
		 var fs=9+18*(json["WSU"][key]-min)/(max-min);
		 topten+='<a class=mytag style="font-size:'+fs+'px" onclick="refine(\'WSU\',\''+key+'\')">'+key+'</a>  ';
	 }
	 if(i>=20){topten+='</span><a style="cursor:pointer" onclick="this.previousSibling.style.display=this.previousSibling.style.display==\'\'?\'none\':\'\';this.innerHTML=this.innerHTML==\'['+I18N["hint"]["showmore"]+']\'?\'['+I18N["hint"]["show20"]+']\':\'['+I18N["hint"]["showmore"]+']\'">['+I18N["hint"]["showmore"]+']</a>';}
      g('kwcon').innerHTML=topten;
      g('kwcon').style.lineHeight="normal";
}

function showtopten(json){
  var topten='';
  if(json["topten"].length>0){
	  for (var i = 0; i < json["topten"].length; i++) {
           topten+='<li><a target=_blank href=/F?func=find-b&'+'con_lng=chi&find_code=SYS&local_base='+json["topten"][i]['lib']+'&request='+json["topten"][i]['docnum']+'>'+json["topten"][i]['title']+'</a>';
      }
      document.write("<ol id=topten>"+topten+"</ol>");
  }else{document.write(I18N["hint"]["blank"]);}
}
var taglist;
function showhottags(json){
  taglist=json;
  var topten='';
  if(taglist["topten"].length>0){
	  for (var i = 0; i < taglist["topten"].length; i++) {
           topten+='<li><a href="/cgi-bin/tag_m.cgi?lib='+libcode+'&sid='+sid+'&find='+taglist["topten"][i]['tag']+'">'+taglist["topten"][i]['tag']+'('+taglist["topten"][i]['count']+')</a>';
      }
      document.write("<ol id=topten>"+topten+"</ol>");
  }else{document.write(I18N["hint"]["blank"]);}
}
function tagcloud(flag){
  var topten='';
  if(flag){
  if(taglist["topten"].length>0){
	  for (var i = 0; i < taglist["topten"].length; i++) {
           var fs=9+18*(taglist["topten"][i]['count']-taglist["min"])/(taglist["max"]-taglist["min"]);
           topten+='<a class=mytag style="font-size:'+fs+'px" href="/cgi-bin/tag_m.cgi?lib='+libcode+'&sid='+sid+'&find='+taglist["topten"][i]['tag']+'">'+taglist["topten"][i]['tag']+'</a>  ';
      }
      g('hottag').innerHTML=topten;
      g('hottag').style.lineHeight="normal";
  }else{g('hottag').innerHTML=I18N["hint"]["blank"];}
  }else{
  if(taglist["topten"].length>0){
	  for (var i = 0; i < taglist["topten"].length; i++) {
           topten+='<li><a href="/cgi-bin/tag_m.cgi?sid='+sid+'&find='+taglist["topten"][i]['tag']+'">'+taglist["topten"][i]['tag']+'('+taglist["topten"][i]['count']+')</a>';
      }
      g('hottag').innerHTML="<ol id=topten>"+topten+"</ol>";
      g('hottag').style.lineHeight="135%";
  }else{g('hottag').innerHTML=I18N["hint"]["blank"];}
  }
}
function covers(json){
    var src;
    for(var key in doclist){
        if(json[key]){
            src=lkbhost+"/cgi-bin/alkb.cgi?id2="+json[key];
        }else{src="/covers/nocover.jpg";}
        g(key).innerHTML="<img style='border:none;' src="+src+">";
    }
}
function fmt_issn(issn){
    if(typeof lkbhost !='undefined' && !flag_sfx)return;
    issn=issn.replace(/ .*/g,"").replace(/[^0-9Xx]/g,"");
    if(issn.length>=8){
        issns[issn]=1;
        w(" <span id=i"+issn+" style='display:none'></span>");
    }
}
function getsfx(oid,obj){
    if(typeof issn_tm[oid]!=undefined)clearTimeout(issn_tm[oid]);
    var odiv=obj.lastChild;
    odiv.style.left=getPos(obj).x+obj.offsetWidth+'px';
    odiv.style.top=getPos(obj).y-2+'px';
    odiv.style.display="";
    if(odiv.innerHTML==""){
        odiv.innerHTML="<img src=/opac_lcl_chi/loading.gif>";
        var request = new XMLRequst("/cgi-bin/asfx.cgi?oid="+oid,"get").createXMLRequst();
        request.onreadystatechange = function(){
            if (request.readyState == 4){
                if (request.status == 200){
                    odiv.innerHTML=request.responseText;
                }
            }
        }
        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        request.send(null);
    }
}
function sfxlink(json){
    for(var key in json){
        g('i'+key).innerHTML="<span onmouseover='getsfx(\""+json[key]+"\",this)' onmouseout='var tobj=this;issn_tm[\""+json[key]+"\"]=setTimeout(function() {tobj.lastChild.style.display=\"none\"}, 250);'><img src=/opac_lcl_chi/go.gif><div class=issnlink style='display:none'></div></span>";
        g('i'+key).style.display="";
    }
}
